﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel.DataAnnotations;
using dbPoll_Application.Models;

namespace dbPoll_Application.ViewModels
{
    public class QueryViewModel
    {
        [Required(ErrorMessage = "Start date is required")]
        public DateTime startTime {get; set; }
        [Required(ErrorMessage = "End date is required")]
        public DateTime endTime { get; set; }
        public ICollection<QuestionAndPoll> questions { get; set; }
        public IList<User> allPollCreators { get; set; }
        public User selectedPollCreator { get; set; }

        public QueryViewModel()
        {
            this.startTime = DateTime.Now;
            this.endTime = DateTime.Now;
            this.questions = null;
            this.allPollCreators = null;
            this.selectedPollCreator = null;
        }

        public QueryViewModel(DateTime startTime, DateTime endTime, IList<User> pollCreators)
        {
            this.startTime = startTime;
            this.endTime = endTime;
            this.questions = new List<QuestionAndPoll>();
            this.allPollCreators = pollCreators;
            this.selectedPollCreator = new User();
        }

        public QueryViewModel(DateTime startTime, DateTime endTime, ICollection<QuestionAndPoll> questions, IList<User> allPollCreators)
        {
            this.startTime = startTime;
            this.endTime = endTime;
            this.questions = questions;
            this.allPollCreators = allPollCreators;
            this.selectedPollCreator = new User();
        }
    }
}
